package com.qingpeng.pay.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.qingpeng.pay.R;
import com.qingpeng.pay.beans.OrderBean;

public class OrderAdapter extends BaseQuickAdapter<OrderBean.DataProductBean.ListProductBean, BaseViewHolder> {
    public OrderAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, OrderBean.DataProductBean.ListProductBean item) {
        helper.setText(R.id.order_number,item.getOrder_sn())
                .setText(R.id.order_money,item.getTradeMoney()+"")
                .setText(R.id.order_time,item.getCreatime())
                .setText(R.id.order_name,item.getName());
        String payType = item.getPayType();
        if (payType.equals("1")){
            helper.setImageResource(R.id.order_image,R.mipmap.ic_order_weixin);
        }else{
            helper.setImageResource(R.id.order_image,R.mipmap.ic_order_alipay);
        }
        String status = item.getStatus();
        if (status.equals("0")){
            helper.setText(R.id.order_status,"未完成");
            helper.setTextColor(R.id.order_status,mContext.getResources().getColor(R.color.c_1c8f4a));
        }else if(status.equals("1")){
            helper.setText(R.id.order_status,"完成");
            helper.setTextColor(R.id.order_status,mContext.getResources().getColor(R.color.c_fe2c2d));
        }else if(status.equals("2")){
            helper.setText(R.id.order_status,"过期");
            helper.setTextColor(R.id.order_status,mContext.getResources().getColor(R.color.c_878586));
        }else if(status.equals("3")){
            helper.setText(R.id.order_status,"取消");
            helper.setTextColor(R.id.order_status,mContext.getResources().getColor(R.color.c_878586));
        }
    }
}
